#
# Hill, Seth J. and Chris Tausanovitch. "A Disconnect in Representation? Comparison of Trends in Congressional and Public Polarization."
#

loc <- ""

files <- list.files(loc,pattern="simulatePolarization")[-1] 
p <- rep(NA,length(files))
ratio <- rep(NA,length(files))
for (i in 1:length(p)){
    load(paste(loc,files[i],sep=""))
    sds1 <- apply(bigRes$output[[1]][,1:2000],1,sd)
    sds2 <- apply(bigRes$output[[1]][,2001:4000],1,sd)
    p[i] <- sum(sds1-sds2 > 0)/length(sds1)
    ratio[i] <- median(sds2/sds1)
}

length(p)
summary(p)
table(p>.05)
summary(ratio)

